<div style="float: left;">
<div class="ui-corner-top side_menu" style="width: 700px;">Student Profile</div>
<div style="border:1px  solid #286bcc;">
<div>&nbsp;</div>
<div>
<?echo validation_errors();?>
<?if(isset($system_message))echo $system_message;?>

<?php 

	if(!empty($student)):


	/***
	Assign student room form	
	***/ 
	if(empty($student->room_id)) $room_id = '';
	else $room_id = $student->room_id;
	
	echo form_open('teacher/view_profile/'.$student->profile_id, array('class' => 'admin-form'));
	if(!empty($rooms)){
		$roomAttrib = array('' => 'Select Room...');
	
		foreach($rooms as $room){
			$roomAttrib[$room->room_id] = $room->name;
		}
	}
	else
		$roomAttrib = array('' => 'No rooms available for this level yet..');
?>

	<?php echo form_fieldset('Room Assignment') ?>
    <div class="input-block">
        <?php
            echo form_label('Room assignment', 'room_id');
            echo form_dropdown('room_id', $roomAttrib, $room_id);		
            echo form_hidden('profile_id', $student->profile_id);
        ?>
    </div>
    
    <div class="input-block">
        <?php echo form_submit('assign', 'Assign');?>
    </div>
    <?php echo form_fieldset_close()?>

<?php 
	/***
	Edit Student Information
	***/
	echo form_open('teacher/view_profile/'.$student->profile_id, array('class' => 'admin-form'));
?>

<div class="inner-border">
	<?php
$formAttrib = array('class'=> 'admin-form', 'name' => 'frm_addstudent');
$idNo = $student->idno;
$studentTypeAttrib = array('' => 'Select Student Type...', 'new' => 'New', 'old' => 'Old', 'returnee' => 'Returnee', 'cross' => 'Cross' );

//Account Details
$idNoAttrib = array('name' => 'idno', 'value' => $idNo, 'id' => 'idno', 'readonly' => 'readonly');
$userNameAttrib = array('name' => 'username', 'value' => $idNo, 'id' => 'username', 'readonly' => 'readonly');
$passwordAttrib = array('name' => 'password', 'value' => $idNo, 'id' => 'password', 'readonly' => 'readonly');


if(!empty($levels)){
	$levelAttrib = array('' => 'Select level...');
	foreach($levels as $level){
		$levelAttrib[$level->level_id] = strtoupper($level->level_code).' - '.$level->level_desc;
	}
}
else
{
	$levelAttrib = array('' => 'No levels available');
}
$dob = explode('-', $student->dob);
// Personal Information fields
$lNameAttrib = array('name' => 'lastname', 'id' => 'lastname', 'value' => $student->lastname);
$fNameAttrib = array('name' => 'firstname', 'id' => 'firstname', 'value' => $student->firstname);
$mNameAttrib = array('name' => 'middlename', 'id' => 'middlename', 'value' => $student->middlename);
$genderAttrib = array('' => 'Select Gender...', 'male' => 'Male', 'female' => 'Female' );
$civilStatusAttrib = array('' => 'Select Civil Status...', 'single' => 'Single', 'married' => 'Married', 'divorced' => 'Divorced' );
$dobAttrib = array('name' => 'dob', 'id' => 'dob', 'value' => $dob[2].'/'.$dob[1].'/'.$dob[0], 'class' => 'datepicker');
$pobAttrib = array('name' => 'pob', 'id' => 'pob', 'value' => $student->pob);
$ageAttrib = array('name' => 'age', 'id' => 'age', 'value' => $student->age);
$disabilityAttrib = array('name' => 'disability', 'id' => $student->disability);
$nationalityAttrib = array('name' => 'nationality', 'id' => 'nationality', 'value' => $student->nationality);
$religionAttrib = array('name' => 'religion', 'id' => 'religion', 'value' => $student->religion);
$contactNumberAttrib = array('name' => 'contact_no', 'id' => 'contact_no', 'value' => $student->contact_no);
$emailAttrib = array('name' => 'email', 'id' => 'email', 'value' => $student->email);
$presentAddressAttrib = array('name' =>'present_address', 'id' => 'present_address', 'value' => $student->present_address);
$fatherNameAttrib = array('name' => 'fathername', 'id' => 'fathername', 'value' => $student->fathername);
$fatherOccupationAttrib = array('name' => 'father_occupation', 'id' => 'father_occupation', 'value' => $student->father_occupation);
$fatherContactAttrib = array('name' => 'father_contact_no', 'id' => 'father_contact_no', 'value' => $student->father_contact_no);
$motherNameAttrib = array('name' => 'mothername', 'id' => 'mothername', 'value' => $student->mothername);
$motherOccupationAttrib = array('name' => 'mother_occupation', 'id' => 'mother_occupation', 'value' => $student->mother_occupation);
$motherContactAttrib = array('name' => 'mother_contact_no', 'id' => 'mother_contact_no', 'value' => $student->mother_contact_no);
$parentAddressAttrib = array('name' => 'parent_address', 'id' => 'parent_address', 'value' => $student->parent_address);
$guardianNameAttrib = array('name' => 'guardian_name', 'id' => 'guardian_name', 'value' => $student->guardian_name);
$relationshipAttrib = array('name' => 'relationship', 'id' => 'relationship', 'value' => $student->relationship);
$guardianContactAttrib = array('name' => 'guardian_contact_no', 'id' => 'guardian_contact_no', 'value' => $student->guardian_contact_no);
$guardianAddressAttrib = array('name' => 'guardian_address', 'id' => 'guardian_address', 'value' => $student->guardian_address);

// Last school attended
$lSchoolNameAttrib= array('name' => 'last_school_name', 'id' => 'last_school_name', 'value' => $student->last_school_name);
$lSchoolAddressAttrib = array('name' => 'last_school_address', 'id' => 'last_school_address', 'value' => $student->last_school_address);
$lSchoolLevelAttrib = array('name' => 'last_school_level', 'id' => 'last_school_level', 'value' => $student->last_school_level);
$lSchoolYearAttrib = array('name' => 'last_school_year', 'id' => 'last_school_year', 'value' => $student->last_school_year);

?>


<?php echo form_fieldset('Account Details');?>

<div class="input-block">
	<?php
		echo form_label('IDNO', 'idno');
		echo form_input($idNoAttrib);
		echo form_hidden('aprofile_id', $student->profile_id);		
	?>
</div>
<div class="input-block">
 	<?php
		echo form_label('Student type <strong>*</strong>', 'student_type');
    	echo form_dropdown('student_type', $studentTypeAttrib, $student->student_type);
	?>
</div>
    
   <div class="input-block">
	<?php
		echo form_label('Level <strong>*</strong>', 'year_level_id');
    	echo form_dropdown('level_id', $levelAttrib, $student->level_id);
	?>
    </div>
<?php echo form_fieldset_close(); ?>

<?php echo form_fieldset('Personal Information');?>
<div class="input-block">
 	<?php
		echo form_label('Last Name <strong>*</strong>', 'lastname');
    	echo form_input($lNameAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('First Name <strong>*</strong>', 'firstname');
    	echo form_input($fNameAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Middle Name <strong>*</strong>', 'middlename');
    	echo form_input($mNameAttrib);
	?>
</div>


<div class="input-block">
 	<?php
		echo form_label('Gender <strong>*</strong>', 'gender');
    	echo form_dropdown('gender', $genderAttrib, $student->gender);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Civil Status <strong>*</strong>', 'civilstatus');
    	echo form_dropdown('civilstatus', $civilStatusAttrib, $student->civilstatus);
	?>
</div>


<div class="input-block">
 	<?php
		echo form_label('Date of Birth <strong>*</strong>', 'dob');
    	echo form_input($dobAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Place of Birth <strong>*</strong>', 'pob');
    	echo form_input($pobAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Age <strong>*</strong>', 'age');
    	echo form_input($ageAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Disability', 'disability');
    	echo form_input($disabilityAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Nationality <strong>*</strong>', 'nationality');
    	echo form_input($nationalityAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Religion <strong>*</strong>', 'religion');
    	echo form_input($religionAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Contact Number <strong>*</strong>', 'contact_no');
    	echo form_input($contactNumberAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Email <strong>*</strong>', 'email');
    	echo form_input($emailAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Present Address <strong>*</strong>', 'present_address');
    	echo form_input($presentAddressAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Father\'s Name <strong>*</strong>', 'fathername');
    	echo form_input($fatherNameAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Occupation <strong>*</strong>', 'father_occupation');
    	echo form_input($fatherOccupationAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Contact Number <strong>*</strong>', 'father_contact_no');
    	echo form_input($fatherContactAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Mother\'s Name <strong>*</strong>', 'mothername');
    	echo form_input($motherNameAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Occupation <strong>*</strong>', 'mother_occupation');
    	echo form_input($motherOccupationAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Contact Number <strong>*</strong>', 'mother_contact_no');
    	echo form_input($motherContactAttrib);	
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Parent\'s Address <strong>*</strong>', 'parent_address');
    	echo form_input($parentAddressAttrib);	
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Guardian Name <strong>*</strong>', 'guardian_name');
    	echo form_input($guardianNameAttrib);	
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Relationship <strong>*</strong>', 'relationship');
    	echo form_input($relationshipAttrib);	
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Contact Number <strong>*</strong>', 'guardian_contact_no');
    	echo form_input($guardianContactAttrib);	
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Guardian Address <strong>*</strong>', 'guardian_address');
    	echo form_input($guardianAddressAttrib);	
	?>
</div>

<?php echo form_fieldset_close();?>

<?php echo form_fieldset('Last school attended');?>

<div class="input-block">
 	<?php
		echo form_label('School Name <strong>*</strong>', 'last_school_name');
    	echo form_input($lSchoolNameAttrib);	
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('School Address <strong>*</strong>', 'last_school_address');
    	echo form_input($lSchoolAddressAttrib);	
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Level <strong>*</strong>', 'last_school_level');
    	echo form_input($lSchoolLevelAttrib);
	?>
</div>

<div class="input-block">
 	<?php
		echo form_label('Year<strong>*</strong>', 'last_school_year');
    	echo form_input($lSchoolYearAttrib);	
	?>
</div>



<?php echo form_fieldset_close();?>

<div class="input-block">
	<a href="<?=site_url('teacher/students');?>" class="btn">Back</a>
 	<?php echo form_submit('update', 'Update');?>
</div>

</div>

<?php
echo form_close();
?>

</div>
<?php else:?>
Invalid student
<?php endif;?>
<div class="clearfloat"></div>
</div>
<div>&nbsp;</div>
</div>